package com.nuc.dip2;

/**
 * Time    : 2023/3/24 21:58
 * Author  : 王摇摆
 * FileName: Driver.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class Driver {
    private String driverName;

    public Driver(String driverName) {
        this.driverName = driverName;
    }

    public String getDriverName() {
        return driverName;
    }

    //核心语句，这里的参数应该放置车的依赖，应该把接口作为形参，然后使用多态的思想，使得父类引用使用子类的方法
    public void drive(ICar car) {
        car.run(this.getDriverName());
    }
}
